//
// Description: 1974. 使用特殊打字机键入单词的最少时间
// Created by Loading on 2021/10/9.
//

#include <bits/stdc++.h>

using namespace std;

int minTimeToType(string word) {
    int res = 0;
    char last = 'a';

    for (auto &c : word) {
        res += min((last - c + 26) % 26, (c - last + 26) % 26) + 1;
        last = c;
    }

    return res;
}

int main() {
    string word = "abc";
    int res = minTimeToType(word);
    cout << res << endl;

    return 0;
}